Skip to content

Conversation

ahtesham-quraish
Copy link
Contributor

Description

#2316.

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for manually testing this change.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 97.39130% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.42%. Comparing base (8326257) to head (2dfe074).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ingsWidget/settingsComponents/SwitchEditorCard.jsx 91.66% 1 Missing ⚠️
src/editors/containers/TextEditor/index.jsx 94.73% 1 Missing ⚠️
...eoSettingsModal/components/HandoutWidget/index.jsx 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2341      +/-   ##
==========================================
+ Coverage   94.40%   94.42%   +0.01%     
==========================================
  Files        1167     1168       +1     
  Lines       24957    24985      +28     
  Branches     5303     5304       +1     
==========================================
+ Hits        23561    23591      +30     
+ Misses       1329     1327       -2     
  Partials       67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahtesham-quraish ahtesham-quraish changed the title Ahtesham/#2316 Replace connect with useSelector() and useDispatch() 3/5 #2316 Jul 30, 2025
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

For reviewers, please don't merge this until we've merged #2343 and rebased this on top of it. I suggest holding off on review until then as well.

const intl = useIntl();
const { editorRef, refReady, setEditorRef } = prepareEditorRef();

// Select state values using useSelector

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove comment line.

@bradenmacdonald
Copy link
Contributor

@ahtesham-quraish Could you please take another look at this PR, and rebase it etc.? I'd appreciate if you can help get all your PRs green and ready for review, and address all outstanding comments before opening any more new PRs. I'll try to help with your coverage questions where I can, but I'm a little behind in my reviews at the moment. Thanks!

Comment on lines +1 to +39
import React from 'react';
import { Provider } from 'react-redux';
import { render as baseRender } from '../testUtils';
import { EditorContextProvider } from './EditorContext';
import { initializeStore } from './data/redux'; // adjust path if needed

/**
* Custom render function for testing React components with the editor context and Redux store.
*
* Wraps the provided UI in both the EditorContextProvider and Redux Provider,
* ensuring that components under test have access to the necessary context and store.
*
* @param {React.ReactElement} ui - The React element to render.
* @param {object} [options] - Optional parameters.
* @param {object} [options.initialState] - Optional initial state for the store.
* @param {string} [options.learningContextId] - Optional learning context ID.
* @returns {RenderResult} The result of the render, as returned by RTL render.
*/
const editorRender = (
ui,
{
initialState = {},
learningContextId = 'course-v1:Org+COURSE+RUN',
} = {},
) => {
const store = initializeStore(initialState);

return baseRender(ui, {
extraWrapper: ({ children }) => (
<EditorContextProvider learningContextId={learningContextId}>
<Provider store={store}>
{children}
</Provider>
</EditorContextProvider>
),
});
};

export default editorRender;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file and just use the existing editorRender function. Generally, this PR has the same issues as #2346 which I just reviewed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants